<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ path + "/";
%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <base href="<%=basePath%>">
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta content="telephone=no,email=no" name="format-detection">
    <meta name="wap-font-scale" content="no">
    <title>常用信息</title>
    <!-- 公用样式css -->
    <link rel="stylesheet" href="css/base.css"/>
    <link rel="stylesheet" href="css/card-package.css"/>
    <link rel="stylesheet" href="css/idangerous.swiper.css"/>
    <link rel="stylesheet" href="css/interests-member.css"/>
    <link rel="stylesheet" href="css/supplement.css"/>
    <link rel="stylesheet" href="css/slide/slide.css"/>
    <style media="screen">
        * {margin: 0;padding: 0;}
        ul {list-style: none;}
        .sl-content {
            overflow: hidden;
        }
        .sl-content img {
            width: 120px;
            height: auto;
            margin-right: 8px;
            float: left;
        }
    </style>
</head>
<body ontouchstart>
<%-- <header class="header">
   <a href="<%=basePath%>member/memberCenter" class="header-left"><img class="img-home" src="images/return.png" /></a>
    <div class="header-center word5 "><a class="header-arrow">常用信息</a></div>
</header> --%>
<div class="main bot44" style="background:#fff;">
    <div class="tabs">
        <a href="<%=basePath%>member/getMemCheckInList" hidefocus="true">入住人</a>
        <a href="<%=basePath%>member/getMemInvoiceList" hidefocus="true" class="active">发票</a>
        <a href="<%=basePath%>member/getMemAddressList" hidefocus="true">地址</a>
    </div>
    <div class="swiper-container">
        <div class="swiper-wrapper">
            <div class="swiper-slide">
                <div class="common-tj">
                    <button class="button-rzr wor-colour6" onclick="_addInfo();return false;">添加发票</button>
                </div>
                <ul class="common-list3">
                    <c:if test="${not empty dataList}">
                        <c:forEach var="info" items="${dataList}">
                            <li class="sl-li ui-border-b"  style="border-bottom: 2px solid #eee;">
                                <div class="sl-content">
                                    <p>${info.Title}</p>
                                    <p>识别号：${info.CreditCode}</p>
                                    <c:if test="${info.DefaultSign}">
                                    	<div class="slDefaultDiv">
                                        <p class="float-l common-button">默认</p>
                                        </div>
                                    </c:if>
                                    <c:if test="${!info.DefaultSign}">
                                    <div class="slDefaultDiv">
                                    <div class="fit_box">
                                        <input type="hidden" id="defaultSign">
                                        <input type="radio" value="true" id="setDefault_${info.Code}" name="defaultSign" onclick="_setDefault('${info.Code}');return false;">
                                        <label for="setDefault_${info.Code}"></label>
                                    </div>
                                    <span class="wor-colour8">设为默认</span>
                                    </div>
                                    </c:if>
                                </div>
                                <div class="sl-opts">
                                    <span style="background-color: #F95F61; color: #fff;" onclick="_deleteInfo('${info.Code}');return false;">删除</span>
                                    <c:if test="${info.InvoiceType==1}">
                                    <span style="background-color: #ff9c00; color: #fff;" onclick="_modifyInfo('${info.Code}','${info.InvoiceType}','${info.Title}','${info.CreditCode}',
                                            '${info.RegisterAddress}','${info.CompanyPhone}','','${info.OpeningAccount}',
                                            '${info.TakeType}','${info.DefaultSign}');return false">修改</span>
                                    </c:if>
                                    <c:if test="${info.InvoiceType==2}">
                                    <span style="background-color: #ff9c00; color: #fff;"  onclick="_modifyInfo('${info.Code}','${info.InvoiceType}','${info.Title}',
                                            '${info.CreditCode}','${info.RegisterAddress}','${info.CompanyPhone}',
                                            '${info.OpeningBank}','${info.OpeningAccount}','${info.TakeType}','${info.DefaultSign}');return false">修改</span>
                                    </c:if>
                                </div>
                            </li>
                        </c:forEach>
                    </c:if>
                    <c:if test="${empty dataList}"> <img src="<%=basePath%>/images/icon38.png"></c:if>
                </ul>
            </div>
        </div>
    </div>
</div>
</body>
<script src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="js/idangerous.swiper.min.js"></script>
<script type="text/javascript" src="js/artDialog/artDialog.source.js?skin=simple"></script>
<script type="text/javascript" src="js/artDialog/plugins/iframeTools.source.js"></script>
<script type="text/javascript" src="js/slide/zepto.min.js"></script>
<script type="text/javascript" src="js/slide/slideleft.min.js"></script>

<script type="text/javascript">
    function _setDefault(code) {
        $.ajax({
            url:"<%=basePath%>member/setMemDefaultInvoice",
            type:"post",
            data:{code:code},
            success:function(data){
                if(data.stateID==0&&data.businessState==0){
                    art.dialog.tips('操作成功');
                    window.location.replace('<%=basePath%>member/getMemInvoiceList');
                }else if(data.stateID==4){
                    window.location.replace('<%=basePath%>home/gotoRegister');//注册页面
                }else {
                    art.dialog.tips(data.msgInfo);
                }
            },
            error:function(e){
                art.dialog.tips('操作异常');
                window.location.replace('<%=basePath%>member/getMemInvoiceList');
            }
        });
    }

    function _addInfo() {
        var url = "<%=basePath%>/member/gotoAddOrdinaryInvoice";
        window.location.replace(url);
    }
    function  _deleteInfo(code) {
        $.ajax({
            url:"<%=basePath%>member/delMemInvoice",
            type:"post",
            data:{code:code},
            success:function(data){
                if(data.stateID==0&&data.businessState==0){
                    art.dialog.tips('操作成功');
                    window.location.replace('<%=basePath%>member/getMemInvoiceList');
                }else if(data.stateID==4){
                    window.location.replace('<%=basePath%>home/gotoRegister');//注册页面
                }else {
                    art.dialog.tips(data.msgInfo);
                }
            },
            error:function(e){
                art.dialog.tips('操作异常');
                window.location.replace('<%=basePath%>member/getMemInvoiceList');
            }
        });
    }


    function  _modifyInfo(code,invoiceType,title,creditCode,registerAddress,companyPhone,openingBank,openingAccount,takeType,defaultSign) {
        var url ="";
        if(invoiceType==1){//普通
            url = "<%=basePath%>member/gotoEditOrdinaryInvoice?code="+code+"&invoiceType="+invoiceType+"&title="+title+"&creditCode="+creditCode+"&takeType="+takeType+"&defaultSign="+defaultSign;
        }else if(invoiceType==2){//增值税
            url = "<%=basePath%>member/gotoEditValueInvoice?code="+code+"&invoiceType="+invoiceType+"&title="+title+"&creditCode="+creditCode
            +"&registerAddress="+registerAddress+"&companyPhone="+companyPhone+"&openingBank="+openingBank+"&openingAccount="+openingAccount
                +"&takeType="+takeType+"&defaultSign="+defaultSign;
        }
        window.location.replace(url);
    }
</script>
</html>
